﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace HelloOne.NewsSvc.Infrastructure
{
    public class AttributeHelper
    {
        public static T GetAttribute<T>(object value) where T : Attribute
        {
            var type = value.GetType();

            var name = Enum.GetName(type, value);

            var filed = type.GetField(name);

            var attribute = Attribute.GetCustomAttribute(filed, typeof(T));

            return (T)attribute;
        }
    }
}